import React from "react";
import ReactDOM from "react-dom";
import {HashRouter as Router, Route, Redirect, Switch} from "react-router-dom"
import {Provider} from "mobx-react";
import allStore from "./stores";
import {asyncComponent} from "react-async-component";
import {Tools} from "weaver-mobile";

import "./style";

const getLocaleLabel = Tools.getLocaleLabel.bind(this, "ecme_mobile");

const coms = {
    Main: asyncComponent({
        resolve: () => import("./components/main")
    }),
    Card: asyncComponent({
        resolve: () => import('./components/card')
    })
}

class Root extends React.Component {
    render() {
        return (
            <Provider {...allStore}>
                <Router>
                    <Route name="main" path="/" onEnter={getLocaleLabel} render={() => (
                        <coms.Main>
                            <Switch>
                                <Route name="card" path="/index/card" component={coms.Card}/>
                            </Switch>
                        </coms.Main>
                    )}/>
                </Router>
            </Provider>
        )
    }
}

Tools.getLocaleLabel('ecme_mobile',() => {
    ReactDOM.render(<Root />,document.getElementById('root'));
  })
